#ifndef _BRIDGET_COMMUNICATOR_H
#define _BRIDGET_COMMUNICATOR_H

/******************************************************************************
** @file	bridget_communicator.h
** @author	Arturo Aguilar
** @author	Andrea Herbas
** @date	Ago 29, 2010
**
** @desc	This class communicates the client with the parts that recover 
**          the computers and its data (shares, files, dirs and registries).
*			
**
******************************************************************************/

#include <string>
#include <iostream>
#include <vector>
#include <cm_dblitemanager.h>
#include <wmi_reader.h>
#include <adcm_domain.h>
#include <cm_resultcollection.h>
#include "bc_comparator.h"
#include "bc_common.h"
#include "bc_utils.h"

class BCEXPORT bridget_communicator
{
public:
	static void
	initCom();

	static void 
	closeCom();

    /**
    * Saves a data collection (shares, files, dirs and registries) of an specific computer.
    *
    * @param computer id related to the data that has to be stored.
    * @param structure that encapsulates the computer data (shares, files, dirs and registries).
    * @return a flag that indicates the state of the transaction.
    */
    static WMI_HResult 
    save(int idComputer, CM_ResultCollection& resultCollection);
   
    /**
    * Saves a collection of computers obtained in a specific domain.
    *
    * @param a list of computers discovered.
    * @return a flag that indicates the state of the transaction.
    */
    static WMI_HResult 
    save(const wstring& dc, const wstring& fqdn, vector<ADCM_Computer>& computers);
   
    /**
    * Compares the last two entries of computers data recovered and returns
    * the data that has changed.
    *
    * @param computer id related to the data that has to be stored.
    * @param structure that encapsulates the data that has changed(shares, files, dirs and registries).
    * @return a flag that indicates the state of the transaction.
    */
    static WMI_HResult 
    getDifferences(int idComputer, CM_ResultCollection& resultCollection);

    /**
    * Recovers a list of computers that are in a common domain
    *
    * @param domain controller name.
    * @param fully qualified domain name.
    * @param user included in the domain, the one from 
    *        the computers will be discovered.
    * @param password 
    * @param output paramenter, a list of computers discovered in the
    *        defined domain.
    * @return a flag that indicates the state of the transaction.
    */
    static WMI_HResult 
    getComputers(wstring& dc, wstring& fqdn, wstring& user, 
                wstring& password, vector<ADCM_Computer>& computers);

    /**
    * Obtains a specific computer data (shares, file, dirs and registries).
    *
    * @param computer id.
    * @param output paramenter, structure that encapsulates the data obtained 
    *        from a computer(shares, files, dirs and registries).
    * @param user name
    * @param user password
    * @param ip address of the computer from the data will be obtained.
    * @param false if the connection needed is for retrieve registries, true is used
    *        for the rest of the objects.
    * @param true if the connection is local, otherwise false (remote connection).
    * @return a flag that indicates the state of the transaction.
    */
    static WMI_HResult 
    getComputersResult(int idComputer, CM_ResultCollection* resultCollection, wstring& user, 
					   wstring& password, wstring& host, wstring& fqdn, bool localActive);

	static WMI_HResult 
	getComputers(const wstring fqdn, vector<ADCM_Computer>& computersDB);
};

#endif